package com.amkai.mobile.client.options;



import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

import com.amkai.mobile.client.About;
import com.amkai.mobile.client.R;

/**
 * 
 * @author peter
 * 
 */
public class OptionsProvider {

	public static boolean onCreateOptionsMenu(Activity parent, Menu menu) {

		MenuInflater inflater = parent.getMenuInflater();
		inflater.inflate(R.menu.setup_menu, menu);

		return true;
	}

	public static boolean onOptionsItemSelected(Activity parent, MenuItem item) {
		switch (item.getItemId()) {
		case R.id.menu_aboutaemobile:
			Intent intent = new Intent();
			intent.setClass(parent, About.class);
			parent.startActivity(intent);
			return true;
		case R.id.menu_connection:
//			parent.setContentView(R.layout.connection_setup);
			intent = new Intent();
			intent.setClass(parent, ConnectionSetup.class);
			parent.startActivity(intent);

			return true;
		case R.id.menu_preference:
			intent = new Intent();
			intent.setClass(parent, Preferences.class);
			parent.startActivity(intent);
			return true;
		}

		return false;
	}

//	public void connectionMenu(final Activity parent) {
// 
//		
//		String serverString = MobileDb.getLoginParameter(parent, Constants.SERVER);
//		
//		parent.setContentView(R.layout.connection_setup);
//		Button btn_save = (Button) parent.findViewById(R.id.btnsave);
//		
//		final EditText	server = (EditText) parent.findViewById(R.id.server);
//		final EditText	username = (EditText) parent.findViewById(R.id.username);
//		final EditText	password = (EditText) parent.findViewById(R.id.password);
//		
//		if (serverString == null || serverString.length() == 0) {
//			
//
//			btn_save.setOnClickListener(new OnClickListener() {
//
//				@Override
//				public void onClick(View v) {
//
//					MobileDb.insertConnection(parent, username.getText().toString(), password.getText().toString(), server.getText().toString());
//
//				}
//			});
//
//
//		}else{
//			server.setText(MobileDb.getLoginParameter(parent, Constants.SERVER));
//			username.setText(MobileDb.getLoginParameter(parent, Constants.PASSWORD));
//		}
//	}
}
